bitkeeper revision 1.1688 (42a561d8CR-Fck16qBCLCOs9F40q3g)
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Tue, 7 Jun 2005 08:59:04 +0000 (08:59 +0000)
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>
Tue, 7 Jun 2005 08:59:04 +0000 (08:59 +0000)
Give the map_dom_mem_cache a better name, and fix a bug in
unmap_domain_mem_with_cache() [it shouldn't actually unmap the page!].
The bug was spotted by George Dunlap.
Signed-off-by: Keir Fraser <keir@xensource.com>
xen/arch/x86/mm.c
xen/arch/x86/shadow.c
xen/include/asm-x86/shadow.h
xen/include/asm-x86/x86_32/domain_page.h
xen/include/asm-x86/x86_64/domain_page.h

index bda7d9725ae403062342fd636218dba99b889a1c..797b89ed0c3383bb03b16dae0deaa7ca05d5ba0f 100644 (file)
@@ -1940,7 +1940,7 @@ int do_mmu_update(
     struct vcpu *v = current;
     struct domain *d = v->domain;
     u32 type_info;
-    struct map_dom_mem_cache mapcache, sh_mapcache;
+    struct domain_mmap_cache mapcache, sh_mapcache;
 
     LOCK_BIGLOCK(d);
 
@@ -1956,8 +1956,8 @@ int do_mmu_update(
             (void)get_user(done, pdone);
     }
 
-    init_map_domain_mem_cache(&mapcache);
-    init_map_domain_mem_cache(&sh_mapcache);
+    domain_mmap_cache_init(&mapcache);
+    domain_mmap_cache_init(&sh_mapcache);
 
     if ( !set_foreigndom(cpu, foreigndom) )
     {
@@ -2169,8 +2169,8 @@ int do_mmu_update(
     }
 
  out:
-    destroy_map_domain_mem_cache(&mapcache);
-    destroy_map_domain_mem_cache(&sh_mapcache);
+    domain_mmap_cache_destroy(&mapcache);
+    domain_mmap_cache_destroy(&sh_mapcache);
 
     process_deferred_ops(cpu);
 
index cd71ee48af40625be1859c25111ebfb174b8b232..60683518d60c65200ff2728c8583ac04937fd0fa 100644 (file)
@@ -763,8 +763,8 @@ void free_monitor_pagetable(struct vcpu *v)
 
 int
 set_p2m_entry(struct domain *d, unsigned long pfn, unsigned long mfn,
-              struct map_dom_mem_cache *l2cache,
-              struct map_dom_mem_cache *l1cache)
+              struct domain_mmap_cache *l2cache,
+              struct domain_mmap_cache *l1cache)
 {
     unsigned long phystab = pagetable_get_paddr(d->arch.phys_table);
     l2_pgentry_t *l2, l2e;
@@ -808,14 +808,14 @@ alloc_p2m_table(struct domain *d)
     struct pfn_info *page, *l2page;
     l2_pgentry_t *l2;
     unsigned long mfn, pfn;
-    struct map_dom_mem_cache l1cache, l2cache;
+    struct domain_mmap_cache l1cache, l2cache;
 
     l2page = alloc_domheap_page(NULL);
     if ( l2page == NULL )
         return 0;
 
-    init_map_domain_mem_cache(&l1cache);
-    init_map_domain_mem_cache(&l2cache);
+    domain_mmap_cache_init(&l1cache);
+    domain_mmap_cache_init(&l2cache);
 
     d->arch.phys_table = mk_pagetable(page_to_phys(l2page));
     l2 = map_domain_mem_with_cache(page_to_phys(l2page), &l2cache);
@@ -851,8 +851,8 @@ alloc_p2m_table(struct domain *d)
         list_ent = page->list.next;
     }
 
-    destroy_map_domain_mem_cache(&l2cache);
-    destroy_map_domain_mem_cache(&l1cache);
+    domain_mmap_cache_destroy(&l2cache);
+    domain_mmap_cache_destroy(&l1cache);
 
     return 1;
 }
@@ -2682,7 +2682,7 @@ int shadow_fault(unsigned long va, struct cpu_user_regs *regs)
 void shadow_l1_normal_pt_update(
     struct domain *d,
     unsigned long pa, l1_pgentry_t gpte,
-    struct map_dom_mem_cache *cache)
+    struct domain_mmap_cache *cache)
 {
     unsigned long sl1mfn;    
     l1_pgentry_t *spl1e, spte;
@@ -2707,7 +2707,7 @@ void shadow_l1_normal_pt_update(
 void shadow_l2_normal_pt_update(
     struct domain *d,
     unsigned long pa, l2_pgentry_t gpde,
-    struct map_dom_mem_cache *cache)
+    struct domain_mmap_cache *cache)
 {
     unsigned long sl2mfn;
     l2_pgentry_t *spl2e;
@@ -2732,7 +2732,7 @@ void shadow_l2_normal_pt_update(
 void shadow_l3_normal_pt_update(
     struct domain *d,
     unsigned long pa, l3_pgentry_t gpde,
-    struct map_dom_mem_cache *cache)
+    struct domain_mmap_cache *cache)
 {
     BUG(); // not yet implemented
 }
@@ -2742,7 +2742,7 @@ void shadow_l3_normal_pt_update(
 void shadow_l4_normal_pt_update(
     struct domain *d,
     unsigned long pa, l4_pgentry_t gpde,
-    struct map_dom_mem_cache *cache)
+    struct domain_mmap_cache *cache)
 {
     BUG(); // not yet implemented
 }
index 6099a6e8a3a689a90aa03a5c0131ca8d99f1a265..08c4339f1630ae8b57c0c0208f6175ea0b0b487d 100644 (file)
@@ -121,25 +121,25 @@ extern void __shadow_sync_all(struct domain *d);
 extern int __shadow_out_of_sync(struct vcpu *v, unsigned long va);
 extern int set_p2m_entry(
     struct domain *d, unsigned long pfn, unsigned long mfn,
-    struct map_dom_mem_cache *l2cache,
-    struct map_dom_mem_cache *l1cache);
+    struct domain_mmap_cache *l2cache,
+    struct domain_mmap_cache *l1cache);
 extern void remove_shadow(struct domain *d, unsigned long gpfn, u32 stype);
 
 extern void shadow_l1_normal_pt_update(struct domain *d,
                                        unsigned long pa, l1_pgentry_t l1e,
-                                       struct map_dom_mem_cache *cache);
+                                       struct domain_mmap_cache *cache);
 extern void shadow_l2_normal_pt_update(struct domain *d,
                                        unsigned long pa, l2_pgentry_t l2e,
-                                       struct map_dom_mem_cache *cache);
+                                       struct domain_mmap_cache *cache);
 #if CONFIG_PAGING_LEVELS >= 3
 extern void shadow_l3_normal_pt_update(struct domain *d,
                                        unsigned long pa, l3_pgentry_t l3e,
-                                       struct map_dom_mem_cache *cache);
+                                       struct domain_mmap_cache *cache);
 #endif
 #if CONFIG_PAGING_LEVELS >= 4
 extern void shadow_l4_normal_pt_update(struct domain *d,
                                        unsigned long pa, l4_pgentry_t l4e,
-                                       struct map_dom_mem_cache *cache);
+                                       struct domain_mmap_cache *cache);
 #endif
 extern int shadow_do_update_va_mapping(unsigned long va,
                                        l1_pgentry_t val,
index d46f21b67a5ac04c942346dd154e548d74228a25..c8dcb6003a6932cbe77b11e506bc678ba1191857 100644 (file)
@@ -27,31 +27,36 @@ extern void *map_domain_mem(unsigned long pa);
  */
 extern void unmap_domain_mem(void *va);
 
-struct map_dom_mem_cache {
+#define DMCACHE_ENTRY_VALID 1UL
+#define DMCACHE_ENTRY_HELD  2UL
+
+struct domain_mmap_cache {
     unsigned long pa;
     void *va;
 };
 
 static inline void
-init_map_domain_mem_cache(struct map_dom_mem_cache *cache)
+domain_mmap_cache_init(struct domain_mmap_cache *cache)
 {
     ASSERT(cache != NULL);
     cache->pa = 0;
 }
 
 static inline void *
-map_domain_mem_with_cache(unsigned long pa, struct map_dom_mem_cache *cache)
+map_domain_mem_with_cache(unsigned long pa, struct domain_mmap_cache *cache)
 {
     ASSERT(cache != NULL);
+    BUG_ON(cache->pa & DMCACHE_ENTRY_HELD);
 
     if ( likely(cache->pa) )
     {
+        cache->pa |= DMCACHE_ENTRY_HELD;
         if ( likely((pa & PAGE_MASK) == (cache->pa & PAGE_MASK)) )
             goto done;
         unmap_domain_mem(cache->va);
     }
 
-    cache->pa = (pa & PAGE_MASK) | 1;
+    cache->pa = (pa & PAGE_MASK) | DMCACHE_ENTRY_HELD | DMCACHE_ENTRY_VALID;
     cache->va = map_domain_mem(cache->pa);
 
  done:
@@ -60,14 +65,14 @@ map_domain_mem_with_cache(unsigned long pa, struct map_dom_mem_cache *cache)
 }
 
 static inline void
-unmap_domain_mem_with_cache(void *va, struct map_dom_mem_cache *cache)
+unmap_domain_mem_with_cache(void *va, struct domain_mmap_cache *cache)
 {
     ASSERT(cache != NULL);
-    unmap_domain_mem(va);
+    cache->pa &= ~DMCACHE_ENTRY_HELD;
 }
 
 static inline void
-destroy_map_domain_mem_cache(struct map_dom_mem_cache *cache)
+domain_mmap_cache_destroy(struct domain_mmap_cache *cache)
 {
     ASSERT(cache != NULL);
     if ( likely(cache->pa) )
index 2a59fb1e5e68ce8511c73a15c435103e86cea5dc..ae0e6d2413622d8bb9b8f75763c34142be436432 100644 (file)
 #define map_domain_mem(_pa)   phys_to_virt(_pa)
 #define unmap_domain_mem(_va) ((void)(_va))
 
-struct map_dom_mem_cache { 
+struct domain_mmap_cache { 
 };
 
-#define init_map_domain_mem_cache(_c)      ((void)(_c))
+#define domain_mmap_cache_init(_c)         ((void)(_c))
 #define map_domain_mem_with_cache(_p,_c)   (map_domain_mem(_p))
 #define unmap_domain_mem_with_cache(_v,_c) ((void)(_v))
-#define destroy_map_domain_mem_cache(_c)   ((void)(_c))
+#define domain_mmap_cache_destroy(_c)      ((void)(_c))
 
 #endif /* __ASM_DOMAIN_PAGE_H__ */